// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate gtype;
extern crate iam_v1;
extern crate lazy_static;
extern crate longrunning;
extern crate lro;
extern crate orgpolicy_v2;
extern crate reqwest;
extern crate rpc;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// Information about the principal, resource, and permission to check.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AccessTuple {
    /// Required. The principal whose access you want to check, in the form of
    /// the email address that represents that principal. For example,
    /// `alice@example.com` or
    /// `my-service-account@my-project.iam.gserviceaccount.com`.
    ///
    /// The principal must be a Google Account or a service account. Other types of
    /// principals are not supported.
    pub principal: std::string::String,

    /// Required. The full resource name that identifies the resource. For example,
    /// `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`.
    ///
    /// For examples of full resource names for Google Cloud services, see
    /// <https://cloud.google.com/iam/help/troubleshooter/full-resource-names>.
    pub full_resource_name: std::string::String,

    /// Required. The IAM permission to check for the specified principal and
    /// resource.
    ///
    /// For a complete list of IAM permissions, see
    /// <https://cloud.google.com/iam/help/permissions/reference>.
    ///
    /// For a complete list of predefined IAM roles and the permissions in each
    /// role, see <https://cloud.google.com/iam/help/roles/reference>.
    pub permission: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AccessTuple {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [principal][crate::model::AccessTuple::principal].
    pub fn set_principal<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.principal = v.into();
        self
    }

    /// Sets the value of [full_resource_name][crate::model::AccessTuple::full_resource_name].
    pub fn set_full_resource_name<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.full_resource_name = v.into();
        self
    }

    /// Sets the value of [permission][crate::model::AccessTuple::permission].
    pub fn set_permission<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.permission = v.into();
        self
    }
}

impl wkt::message::Message for AccessTuple {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.AccessTuple"
    }
}

/// Details about how a specific IAM [Policy][google.iam.v1.Policy] contributed
/// to the access check.
///
/// [google.iam.v1.Policy]: iam_v1::model::Policy
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ExplainedPolicy {
    /// Indicates whether _this policy_ provides the specified permission to the
    /// specified principal for the specified resource.
    ///
    /// This field does _not_ indicate whether the principal actually has the
    /// permission for the resource. There might be another policy that overrides
    /// this policy. To determine whether the principal actually has the
    /// permission, use the `access` field in the
    /// [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.v3.TroubleshootIamPolicyResponse].
    pub access: crate::model::AccessState,

    /// The full resource name that identifies the resource. For example,
    /// `//compute.googleapis.com/projects/my-project/zones/us-central1-a/instances/my-instance`.
    ///
    /// If the user who created the
    /// [Replay][google.cloud.policysimulator.v1.Replay] does not have
    /// access to the policy, this field is omitted.
    ///
    /// For examples of full resource names for Google Cloud services, see
    /// <https://cloud.google.com/iam/help/troubleshooter/full-resource-names>.
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    pub full_resource_name: std::string::String,

    /// The IAM policy attached to the resource.
    ///
    /// If the user who created the
    /// [Replay][google.cloud.policysimulator.v1.Replay] does not have
    /// access to the policy, this field is empty.
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    pub policy: std::option::Option<iam_v1::model::Policy>,

    /// Details about how each binding in the policy affects the principal's
    /// ability, or inability, to use the permission for the resource.
    ///
    /// If the user who created the
    /// [Replay][google.cloud.policysimulator.v1.Replay] does not have
    /// access to the policy, this field is omitted.
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    pub binding_explanations: std::vec::Vec<crate::model::BindingExplanation>,

    /// The relevance of this policy to the overall determination in the
    /// [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.v3.TroubleshootIamPolicyResponse].
    ///
    /// If the user who created the
    /// [Replay][google.cloud.policysimulator.v1.Replay] does not have
    /// access to the policy, this field is omitted.
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    pub relevance: crate::model::HeuristicRelevance,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ExplainedPolicy {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [access][crate::model::ExplainedPolicy::access].
    pub fn set_access<T: std::convert::Into<crate::model::AccessState>>(mut self, v: T) -> Self {
        self.access = v.into();
        self
    }

    /// Sets the value of [full_resource_name][crate::model::ExplainedPolicy::full_resource_name].
    pub fn set_full_resource_name<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.full_resource_name = v.into();
        self
    }

    /// Sets the value of [policy][crate::model::ExplainedPolicy::policy].
    pub fn set_policy<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<iam_v1::model::Policy>,
    {
        self.policy = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [policy][crate::model::ExplainedPolicy::policy].
    pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<iam_v1::model::Policy>,
    {
        self.policy = v.map(|x| x.into());
        self
    }

    /// Sets the value of [binding_explanations][crate::model::ExplainedPolicy::binding_explanations].
    pub fn set_binding_explanations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::BindingExplanation>,
    {
        use std::iter::Iterator;
        self.binding_explanations = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [relevance][crate::model::ExplainedPolicy::relevance].
    pub fn set_relevance<T: std::convert::Into<crate::model::HeuristicRelevance>>(
        mut self,
        v: T,
    ) -> Self {
        self.relevance = v.into();
        self
    }
}

impl wkt::message::Message for ExplainedPolicy {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.ExplainedPolicy"
    }
}

/// Details about how a binding in a policy affects a principal's ability to use
/// a permission.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct BindingExplanation {
    /// Required. Indicates whether _this binding_ provides the specified
    /// permission to the specified principal for the specified resource.
    ///
    /// This field does _not_ indicate whether the principal actually has the
    /// permission for the resource. There might be another binding that overrides
    /// this binding. To determine whether the principal actually has the
    /// permission, use the `access` field in the
    /// [TroubleshootIamPolicyResponse][google.cloud.policytroubleshooter.v3.TroubleshootIamPolicyResponse].
    pub access: crate::model::AccessState,

    /// The role that this binding grants. For example,
    /// `roles/compute.serviceAgent`.
    ///
    /// For a complete list of predefined IAM roles, as well as the permissions in
    /// each role, see <https://cloud.google.com/iam/help/roles/reference>.
    pub role: std::string::String,

    /// Indicates whether the role granted by this binding contains the specified
    /// permission.
    pub role_permission: crate::model::binding_explanation::RolePermission,

    /// The relevance of the permission's existence, or nonexistence, in the role
    /// to the overall determination for the entire policy.
    pub role_permission_relevance: crate::model::HeuristicRelevance,

    /// Indicates whether each principal in the binding includes the principal
    /// specified in the request, either directly or indirectly. Each key
    /// identifies a principal in the binding, and each value indicates whether the
    /// principal in the binding includes the principal in the request.
    ///
    /// For example, suppose that a binding includes the following principals:
    ///
    /// * `user:alice@example.com`
    /// * `group:product-eng@example.com`
    ///
    /// The principal in the replayed access tuple is `user:bob@example.com`. This
    /// user is a principal of the group `group:product-eng@example.com`.
    ///
    /// For the first principal in the binding, the key is
    /// `user:alice@example.com`, and the `membership` field in the value is set to
    /// `MEMBERSHIP_NOT_INCLUDED`.
    ///
    /// For the second principal in the binding, the key is
    /// `group:product-eng@example.com`, and the `membership` field in the value is
    /// set to `MEMBERSHIP_INCLUDED`.
    pub memberships: std::collections::HashMap<
        std::string::String,
        crate::model::binding_explanation::AnnotatedMembership,
    >,

    /// The relevance of this binding to the overall determination for the entire
    /// policy.
    pub relevance: crate::model::HeuristicRelevance,

    /// A condition expression that prevents this binding from granting access
    /// unless the expression evaluates to `true`.
    ///
    /// To learn about IAM Conditions, see
    /// <https://cloud.google.com/iam/docs/conditions-overview>.
    pub condition: std::option::Option<gtype::model::Expr>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl BindingExplanation {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [access][crate::model::BindingExplanation::access].
    pub fn set_access<T: std::convert::Into<crate::model::AccessState>>(mut self, v: T) -> Self {
        self.access = v.into();
        self
    }

    /// Sets the value of [role][crate::model::BindingExplanation::role].
    pub fn set_role<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.role = v.into();
        self
    }

    /// Sets the value of [role_permission][crate::model::BindingExplanation::role_permission].
    pub fn set_role_permission<
        T: std::convert::Into<crate::model::binding_explanation::RolePermission>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.role_permission = v.into();
        self
    }

    /// Sets the value of [role_permission_relevance][crate::model::BindingExplanation::role_permission_relevance].
    pub fn set_role_permission_relevance<
        T: std::convert::Into<crate::model::HeuristicRelevance>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.role_permission_relevance = v.into();
        self
    }

    /// Sets the value of [memberships][crate::model::BindingExplanation::memberships].
    pub fn set_memberships<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<crate::model::binding_explanation::AnnotatedMembership>,
    {
        use std::iter::Iterator;
        self.memberships = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [relevance][crate::model::BindingExplanation::relevance].
    pub fn set_relevance<T: std::convert::Into<crate::model::HeuristicRelevance>>(
        mut self,
        v: T,
    ) -> Self {
        self.relevance = v.into();
        self
    }

    /// Sets the value of [condition][crate::model::BindingExplanation::condition].
    pub fn set_condition<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<gtype::model::Expr>,
    {
        self.condition = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [condition][crate::model::BindingExplanation::condition].
    pub fn set_or_clear_condition<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<gtype::model::Expr>,
    {
        self.condition = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for BindingExplanation {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.BindingExplanation"
    }
}

/// Defines additional types related to [BindingExplanation].
pub mod binding_explanation {
    #[allow(unused_imports)]
    use super::*;

    /// Details about whether the binding includes the principal.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct AnnotatedMembership {
        /// Indicates whether the binding includes the principal.
        pub membership: crate::model::binding_explanation::Membership,

        /// The relevance of the principal's status to the overall determination for
        /// the binding.
        pub relevance: crate::model::HeuristicRelevance,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl AnnotatedMembership {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [membership][crate::model::binding_explanation::AnnotatedMembership::membership].
        pub fn set_membership<
            T: std::convert::Into<crate::model::binding_explanation::Membership>,
        >(
            mut self,
            v: T,
        ) -> Self {
            self.membership = v.into();
            self
        }

        /// Sets the value of [relevance][crate::model::binding_explanation::AnnotatedMembership::relevance].
        pub fn set_relevance<T: std::convert::Into<crate::model::HeuristicRelevance>>(
            mut self,
            v: T,
        ) -> Self {
            self.relevance = v.into();
            self
        }
    }

    impl wkt::message::Message for AnnotatedMembership {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.policysimulator.v1.BindingExplanation.AnnotatedMembership"
        }
    }

    /// Whether a role includes a specific permission.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum RolePermission {
        /// Default value. This value is unused.
        Unspecified,
        /// The permission is included in the role.
        Included,
        /// The permission is not included in the role.
        NotIncluded,
        /// The user who created the
        /// [Replay][google.cloud.policysimulator.v1.Replay] is not
        /// allowed to access the binding.
        ///
        /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
        UnknownInfoDenied,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [RolePermission::value] or
        /// [RolePermission::name].
        UnknownValue(role_permission::UnknownValue),
    }

    #[doc(hidden)]
    pub mod role_permission {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl RolePermission {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Included => std::option::Option::Some(1),
                Self::NotIncluded => std::option::Option::Some(2),
                Self::UnknownInfoDenied => std::option::Option::Some(3),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("ROLE_PERMISSION_UNSPECIFIED"),
                Self::Included => std::option::Option::Some("ROLE_PERMISSION_INCLUDED"),
                Self::NotIncluded => std::option::Option::Some("ROLE_PERMISSION_NOT_INCLUDED"),
                Self::UnknownInfoDenied => {
                    std::option::Option::Some("ROLE_PERMISSION_UNKNOWN_INFO_DENIED")
                }
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for RolePermission {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for RolePermission {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for RolePermission {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Included,
                2 => Self::NotIncluded,
                3 => Self::UnknownInfoDenied,
                _ => Self::UnknownValue(role_permission::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for RolePermission {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "ROLE_PERMISSION_UNSPECIFIED" => Self::Unspecified,
                "ROLE_PERMISSION_INCLUDED" => Self::Included,
                "ROLE_PERMISSION_NOT_INCLUDED" => Self::NotIncluded,
                "ROLE_PERMISSION_UNKNOWN_INFO_DENIED" => Self::UnknownInfoDenied,
                _ => Self::UnknownValue(role_permission::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for RolePermission {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Included => serializer.serialize_i32(1),
                Self::NotIncluded => serializer.serialize_i32(2),
                Self::UnknownInfoDenied => serializer.serialize_i32(3),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for RolePermission {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<RolePermission>::new(
                ".google.cloud.policysimulator.v1.BindingExplanation.RolePermission",
            ))
        }
    }

    /// Whether the binding includes the principal.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Membership {
        /// Default value. This value is unused.
        Unspecified,
        /// The binding includes the principal. The principal can be included
        /// directly or indirectly. For example:
        ///
        /// * A principal is included directly if that principal is listed in the
        ///   binding.
        /// * A principal is included indirectly if that principal is in a Google
        ///   group or Google Workspace domain that is listed in the binding.
        Included,
        /// The binding does not include the principal.
        NotIncluded,
        /// The user who created the
        /// [Replay][google.cloud.policysimulator.v1.Replay] is not
        /// allowed to access the binding.
        ///
        /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
        UnknownInfoDenied,
        /// The principal is an unsupported type. Only Google Accounts and service
        /// accounts are supported.
        UnknownUnsupported,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [Membership::value] or
        /// [Membership::name].
        UnknownValue(membership::UnknownValue),
    }

    #[doc(hidden)]
    pub mod membership {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl Membership {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Included => std::option::Option::Some(1),
                Self::NotIncluded => std::option::Option::Some(2),
                Self::UnknownInfoDenied => std::option::Option::Some(3),
                Self::UnknownUnsupported => std::option::Option::Some(4),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("MEMBERSHIP_UNSPECIFIED"),
                Self::Included => std::option::Option::Some("MEMBERSHIP_INCLUDED"),
                Self::NotIncluded => std::option::Option::Some("MEMBERSHIP_NOT_INCLUDED"),
                Self::UnknownInfoDenied => {
                    std::option::Option::Some("MEMBERSHIP_UNKNOWN_INFO_DENIED")
                }
                Self::UnknownUnsupported => {
                    std::option::Option::Some("MEMBERSHIP_UNKNOWN_UNSUPPORTED")
                }
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for Membership {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for Membership {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for Membership {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Included,
                2 => Self::NotIncluded,
                3 => Self::UnknownInfoDenied,
                4 => Self::UnknownUnsupported,
                _ => Self::UnknownValue(membership::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for Membership {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "MEMBERSHIP_UNSPECIFIED" => Self::Unspecified,
                "MEMBERSHIP_INCLUDED" => Self::Included,
                "MEMBERSHIP_NOT_INCLUDED" => Self::NotIncluded,
                "MEMBERSHIP_UNKNOWN_INFO_DENIED" => Self::UnknownInfoDenied,
                "MEMBERSHIP_UNKNOWN_UNSUPPORTED" => Self::UnknownUnsupported,
                _ => Self::UnknownValue(membership::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for Membership {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Included => serializer.serialize_i32(1),
                Self::NotIncluded => serializer.serialize_i32(2),
                Self::UnknownInfoDenied => serializer.serialize_i32(3),
                Self::UnknownUnsupported => serializer.serialize_i32(4),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for Membership {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Membership>::new(
                ".google.cloud.policysimulator.v1.BindingExplanation.Membership",
            ))
        }
    }
}

/// OrgPolicyViolationsPreview is a resource providing a preview of the
/// violations that will exist if an OrgPolicy change is made.
///
/// The list of violations are modeled as child resources and retrieved via a
/// [ListOrgPolicyViolations][] API call. There are potentially more
/// [OrgPolicyViolations][] than could fit in an embedded field. Thus, the use of
/// a child resource instead of a field.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OrgPolicyViolationsPreview {
    /// Output only. The resource name of the `OrgPolicyViolationsPreview`. It has
    /// the following format:
    ///
    /// `organizations/{organization}/locations/{location}/orgPolicyViolationsPreviews/{orgPolicyViolationsPreview}`
    ///
    /// Example:
    /// `organizations/my-example-org/locations/global/orgPolicyViolationsPreviews/506a5f7f`
    pub name: std::string::String,

    /// Output only. The state of the `OrgPolicyViolationsPreview`.
    pub state: crate::model::PreviewState,

    /// Required. The proposed changes we are previewing violations for.
    pub overlay: std::option::Option<crate::model::OrgPolicyOverlay>,

    /// Output only. The number of [OrgPolicyViolations][] in this
    /// `OrgPolicyViolationsPreview`. This count may differ from
    /// `resource_summary.noncompliant_count` because each
    /// [OrgPolicyViolation][google.cloud.policysimulator.v1.OrgPolicyViolation] is
    /// specific to a resource **and** constraint. If there are multiple
    /// constraints being evaluated (i.e. multiple policies in the overlay), a
    /// single resource may violate multiple constraints.
    ///
    /// [google.cloud.policysimulator.v1.OrgPolicyViolation]: crate::model::OrgPolicyViolation
    pub violations_count: i32,

    /// Output only. A summary of the state of all resources scanned for compliance
    /// with the changed OrgPolicy.
    pub resource_counts:
        std::option::Option<crate::model::org_policy_violations_preview::ResourceCounts>,

    /// Output only. The names of the constraints against which all
    /// `OrgPolicyViolations` were evaluated.
    ///
    /// If `OrgPolicyOverlay` only contains `PolicyOverlay` then it contains
    /// the name of the configured custom constraint, applicable to the specified
    /// policies. Otherwise it contains the name of the constraint specified in
    /// `CustomConstraintOverlay`.
    ///
    /// Format:
    /// `organizations/{organization_id}/customConstraints/{custom_constraint_id}`
    ///
    /// Example: `organizations/123/customConstraints/custom.createOnlyE2TypeVms`
    pub custom_constraints: std::vec::Vec<std::string::String>,

    /// Output only. Time when this `OrgPolicyViolationsPreview` was created.
    pub create_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OrgPolicyViolationsPreview {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::OrgPolicyViolationsPreview::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [state][crate::model::OrgPolicyViolationsPreview::state].
    pub fn set_state<T: std::convert::Into<crate::model::PreviewState>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [overlay][crate::model::OrgPolicyViolationsPreview::overlay].
    pub fn set_overlay<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::OrgPolicyOverlay>,
    {
        self.overlay = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [overlay][crate::model::OrgPolicyViolationsPreview::overlay].
    pub fn set_or_clear_overlay<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::OrgPolicyOverlay>,
    {
        self.overlay = v.map(|x| x.into());
        self
    }

    /// Sets the value of [violations_count][crate::model::OrgPolicyViolationsPreview::violations_count].
    pub fn set_violations_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.violations_count = v.into();
        self
    }

    /// Sets the value of [resource_counts][crate::model::OrgPolicyViolationsPreview::resource_counts].
    pub fn set_resource_counts<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::org_policy_violations_preview::ResourceCounts>,
    {
        self.resource_counts = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [resource_counts][crate::model::OrgPolicyViolationsPreview::resource_counts].
    pub fn set_or_clear_resource_counts<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::org_policy_violations_preview::ResourceCounts>,
    {
        self.resource_counts = v.map(|x| x.into());
        self
    }

    /// Sets the value of [custom_constraints][crate::model::OrgPolicyViolationsPreview::custom_constraints].
    pub fn set_custom_constraints<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.custom_constraints = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [create_time][crate::model::OrgPolicyViolationsPreview::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::OrgPolicyViolationsPreview::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for OrgPolicyViolationsPreview {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.OrgPolicyViolationsPreview"
    }
}

/// Defines additional types related to [OrgPolicyViolationsPreview].
pub mod org_policy_violations_preview {
    #[allow(unused_imports)]
    use super::*;

    /// A summary of the state of all resources scanned for compliance with the
    /// changed OrgPolicy.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct ResourceCounts {
        /// Output only. Number of resources checked for compliance.
        ///
        /// Must equal:  unenforced + noncompliant + compliant + error
        pub scanned: i32,

        /// Output only. Number of scanned resources with at least one violation.
        pub noncompliant: i32,

        /// Output only. Number of scanned resources with zero violations.
        pub compliant: i32,

        /// Output only. Number of resources where the constraint was not enforced,
        /// i.e. the Policy set `enforced: false` for that resource.
        pub unenforced: i32,

        /// Output only. Number of resources that returned an error when scanned.
        pub errors: i32,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl ResourceCounts {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [scanned][crate::model::org_policy_violations_preview::ResourceCounts::scanned].
        pub fn set_scanned<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
            self.scanned = v.into();
            self
        }

        /// Sets the value of [noncompliant][crate::model::org_policy_violations_preview::ResourceCounts::noncompliant].
        pub fn set_noncompliant<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
            self.noncompliant = v.into();
            self
        }

        /// Sets the value of [compliant][crate::model::org_policy_violations_preview::ResourceCounts::compliant].
        pub fn set_compliant<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
            self.compliant = v.into();
            self
        }

        /// Sets the value of [unenforced][crate::model::org_policy_violations_preview::ResourceCounts::unenforced].
        pub fn set_unenforced<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
            self.unenforced = v.into();
            self
        }

        /// Sets the value of [errors][crate::model::org_policy_violations_preview::ResourceCounts::errors].
        pub fn set_errors<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
            self.errors = v.into();
            self
        }
    }

    impl wkt::message::Message for ResourceCounts {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.policysimulator.v1.OrgPolicyViolationsPreview.ResourceCounts"
        }
    }
}

/// OrgPolicyViolation is a resource representing a single resource violating a
/// single OrgPolicy constraint.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OrgPolicyViolation {
    /// The name of the `OrgPolicyViolation`. Example:
    /// organizations/my-example-org/locations/global/orgPolicyViolationsPreviews/506a5f7f/orgPolicyViolations/38ce`
    pub name: std::string::String,

    /// The resource violating the constraint.
    pub resource: std::option::Option<crate::model::ResourceContext>,

    /// The custom constraint being violated.
    pub custom_constraint: std::option::Option<orgpolicy_v2::model::CustomConstraint>,

    /// Any error encountered during the evaluation.
    pub error: std::option::Option<rpc::model::Status>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OrgPolicyViolation {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::OrgPolicyViolation::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [resource][crate::model::OrgPolicyViolation::resource].
    pub fn set_resource<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ResourceContext>,
    {
        self.resource = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [resource][crate::model::OrgPolicyViolation::resource].
    pub fn set_or_clear_resource<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ResourceContext>,
    {
        self.resource = v.map(|x| x.into());
        self
    }

    /// Sets the value of [custom_constraint][crate::model::OrgPolicyViolation::custom_constraint].
    pub fn set_custom_constraint<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<orgpolicy_v2::model::CustomConstraint>,
    {
        self.custom_constraint = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [custom_constraint][crate::model::OrgPolicyViolation::custom_constraint].
    pub fn set_or_clear_custom_constraint<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<orgpolicy_v2::model::CustomConstraint>,
    {
        self.custom_constraint = v.map(|x| x.into());
        self
    }

    /// Sets the value of [error][crate::model::OrgPolicyViolation::error].
    pub fn set_error<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<rpc::model::Status>,
    {
        self.error = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [error][crate::model::OrgPolicyViolation::error].
    pub fn set_or_clear_error<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<rpc::model::Status>,
    {
        self.error = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for OrgPolicyViolation {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.OrgPolicyViolation"
    }
}

/// ResourceContext provides the context we know about a resource.
/// It is similar in concept to google.cloud.asset.v1.Resource, but focuses
/// on the information specifically used by Simulator.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ResourceContext {
    /// The full name of the resource. Example:
    /// `//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1`
    ///
    /// See [Resource
    /// names](https://cloud.google.com/apis/design/resource_names#full_resource_name)
    /// for more information.
    pub resource: std::string::String,

    /// The asset type of the resource as defined by CAIS.
    ///
    /// Example: `compute.googleapis.com/Firewall`
    ///
    /// See [Supported asset
    /// types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
    /// for more information.
    pub asset_type: std::string::String,

    /// The ancestry path of the resource in Google Cloud [resource
    /// hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy),
    /// represented as a list of relative resource names. An ancestry path starts
    /// with the closest ancestor in the hierarchy and ends at root. If the
    /// resource is a project, folder, or organization, the ancestry path starts
    /// from the resource itself.
    ///
    /// Example: `["projects/123456789", "folders/5432", "organizations/1234"]`
    pub ancestors: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ResourceContext {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [resource][crate::model::ResourceContext::resource].
    pub fn set_resource<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.resource = v.into();
        self
    }

    /// Sets the value of [asset_type][crate::model::ResourceContext::asset_type].
    pub fn set_asset_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.asset_type = v.into();
        self
    }

    /// Sets the value of [ancestors][crate::model::ResourceContext::ancestors].
    pub fn set_ancestors<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.ancestors = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ResourceContext {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.ResourceContext"
    }
}

/// The proposed changes to OrgPolicy.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct OrgPolicyOverlay {
    /// Optional. The OrgPolicy changes to preview violations for.
    ///
    /// Any existing OrgPolicies with the same name will be overridden
    /// in the simulation. That is, violations will be determined as if all
    /// policies in the overlay were created or updated.
    pub policies: std::vec::Vec<crate::model::org_policy_overlay::PolicyOverlay>,

    /// Optional. The OrgPolicy CustomConstraint changes to preview violations for.
    ///
    /// Any existing CustomConstraints with the same name will be overridden
    /// in the simulation. That is, violations will be determined as if all
    /// custom constraints in the overlay were instantiated.
    ///
    /// Only a single custom_constraint is supported in the overlay at a time.
    /// For evaluating multiple constraints, multiple
    /// `GenerateOrgPolicyViolationsPreview` requests are made, where each request
    /// evaluates a single constraint.
    pub custom_constraints:
        std::vec::Vec<crate::model::org_policy_overlay::CustomConstraintOverlay>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl OrgPolicyOverlay {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [policies][crate::model::OrgPolicyOverlay::policies].
    pub fn set_policies<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::org_policy_overlay::PolicyOverlay>,
    {
        use std::iter::Iterator;
        self.policies = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [custom_constraints][crate::model::OrgPolicyOverlay::custom_constraints].
    pub fn set_custom_constraints<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::org_policy_overlay::CustomConstraintOverlay>,
    {
        use std::iter::Iterator;
        self.custom_constraints = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for OrgPolicyOverlay {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.OrgPolicyOverlay"
    }
}

/// Defines additional types related to [OrgPolicyOverlay].
pub mod org_policy_overlay {
    #[allow(unused_imports)]
    use super::*;

    /// A change to an OrgPolicy.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct PolicyOverlay {
        /// Optional. The parent of the policy we are attaching to.
        /// Example: "projects/123456"
        pub policy_parent: std::string::String,

        /// Optional. The new or updated OrgPolicy.
        pub policy: std::option::Option<orgpolicy_v2::model::Policy>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl PolicyOverlay {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [policy_parent][crate::model::org_policy_overlay::PolicyOverlay::policy_parent].
        pub fn set_policy_parent<T: std::convert::Into<std::string::String>>(
            mut self,
            v: T,
        ) -> Self {
            self.policy_parent = v.into();
            self
        }

        /// Sets the value of [policy][crate::model::org_policy_overlay::PolicyOverlay::policy].
        pub fn set_policy<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<orgpolicy_v2::model::Policy>,
        {
            self.policy = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [policy][crate::model::org_policy_overlay::PolicyOverlay::policy].
        pub fn set_or_clear_policy<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<orgpolicy_v2::model::Policy>,
        {
            self.policy = v.map(|x| x.into());
            self
        }
    }

    impl wkt::message::Message for PolicyOverlay {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.policysimulator.v1.OrgPolicyOverlay.PolicyOverlay"
        }
    }

    /// A change to an OrgPolicy custom constraint.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct CustomConstraintOverlay {
        /// Optional. Resource the constraint is attached to.
        /// Example: "organization/987654"
        pub custom_constraint_parent: std::string::String,

        /// Optional. The new or updated custom constraint.
        pub custom_constraint: std::option::Option<orgpolicy_v2::model::CustomConstraint>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl CustomConstraintOverlay {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [custom_constraint_parent][crate::model::org_policy_overlay::CustomConstraintOverlay::custom_constraint_parent].
        pub fn set_custom_constraint_parent<T: std::convert::Into<std::string::String>>(
            mut self,
            v: T,
        ) -> Self {
            self.custom_constraint_parent = v.into();
            self
        }

        /// Sets the value of [custom_constraint][crate::model::org_policy_overlay::CustomConstraintOverlay::custom_constraint].
        pub fn set_custom_constraint<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<orgpolicy_v2::model::CustomConstraint>,
        {
            self.custom_constraint = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [custom_constraint][crate::model::org_policy_overlay::CustomConstraintOverlay::custom_constraint].
        pub fn set_or_clear_custom_constraint<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<orgpolicy_v2::model::CustomConstraint>,
        {
            self.custom_constraint = v.map(|x| x.into());
            self
        }
    }

    impl wkt::message::Message for CustomConstraintOverlay {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.policysimulator.v1.OrgPolicyOverlay.CustomConstraintOverlay"
        }
    }
}

/// CreateOrgPolicyViolationsPreviewOperationMetadata is metadata about an
/// OrgPolicyViolationsPreview generations operation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateOrgPolicyViolationsPreviewOperationMetadata {
    /// Time when the request was received.
    pub request_time: std::option::Option<wkt::Timestamp>,

    /// Time when the request started processing, i.e., when the state was set to
    /// RUNNING.
    pub start_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The current state of the operation.
    pub state: crate::model::PreviewState,

    /// Total number of resources that need scanning.
    /// Should equal resource_scanned + resources_pending
    pub resources_found: i32,

    /// Number of resources already scanned.
    pub resources_scanned: i32,

    /// Number of resources still to scan.
    pub resources_pending: i32,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateOrgPolicyViolationsPreviewOperationMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [request_time][crate::model::CreateOrgPolicyViolationsPreviewOperationMetadata::request_time].
    pub fn set_request_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.request_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [request_time][crate::model::CreateOrgPolicyViolationsPreviewOperationMetadata::request_time].
    pub fn set_or_clear_request_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.request_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [start_time][crate::model::CreateOrgPolicyViolationsPreviewOperationMetadata::start_time].
    pub fn set_start_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [start_time][crate::model::CreateOrgPolicyViolationsPreviewOperationMetadata::start_time].
    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [state][crate::model::CreateOrgPolicyViolationsPreviewOperationMetadata::state].
    pub fn set_state<T: std::convert::Into<crate::model::PreviewState>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [resources_found][crate::model::CreateOrgPolicyViolationsPreviewOperationMetadata::resources_found].
    pub fn set_resources_found<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.resources_found = v.into();
        self
    }

    /// Sets the value of [resources_scanned][crate::model::CreateOrgPolicyViolationsPreviewOperationMetadata::resources_scanned].
    pub fn set_resources_scanned<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.resources_scanned = v.into();
        self
    }

    /// Sets the value of [resources_pending][crate::model::CreateOrgPolicyViolationsPreviewOperationMetadata::resources_pending].
    pub fn set_resources_pending<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.resources_pending = v.into();
        self
    }
}

impl wkt::message::Message for CreateOrgPolicyViolationsPreviewOperationMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.CreateOrgPolicyViolationsPreviewOperationMetadata"
    }
}

/// ListOrgPolicyViolationsPreviewsRequest is the request message for
/// [OrgPolicyViolationsPreviewService.ListOrgPolicyViolationsPreviews][google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService.ListOrgPolicyViolationsPreviews].
///
/// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService.ListOrgPolicyViolationsPreviews]: crate::client::OrgPolicyViolationsPreviewService::list_org_policy_violations_previews
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListOrgPolicyViolationsPreviewsRequest {
    /// Required. The parent the violations are scoped to.
    /// Format:
    /// `organizations/{organization}/locations/{location}`
    ///
    /// Example: `organizations/my-example-org/locations/global`
    pub parent: std::string::String,

    /// Optional. The maximum number of items to return. The service may return
    /// fewer than this value. If unspecified, at most 5 items will be returned.
    /// The maximum value is 10; values above 10 will be coerced to 10.
    pub page_size: i32,

    /// Optional. A page token, received from a previous call. Provide this to
    /// retrieve the subsequent page.
    ///
    /// When paginating, all other parameters must match the call that provided the
    /// page token.
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListOrgPolicyViolationsPreviewsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListOrgPolicyViolationsPreviewsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListOrgPolicyViolationsPreviewsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListOrgPolicyViolationsPreviewsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListOrgPolicyViolationsPreviewsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.ListOrgPolicyViolationsPreviewsRequest"
    }
}

/// ListOrgPolicyViolationsPreviewsResponse is the response message for
/// [OrgPolicyViolationsPreviewService.ListOrgPolicyViolationsPreviews][google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService.ListOrgPolicyViolationsPreviews].
///
/// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService.ListOrgPolicyViolationsPreviews]: crate::client::OrgPolicyViolationsPreviewService::list_org_policy_violations_previews
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListOrgPolicyViolationsPreviewsResponse {
    /// The list of OrgPolicyViolationsPreview
    pub org_policy_violations_previews: std::vec::Vec<crate::model::OrgPolicyViolationsPreview>,

    /// A token that you can use to retrieve the next page of results.
    /// If this field is omitted, there are no subsequent pages.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListOrgPolicyViolationsPreviewsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [org_policy_violations_previews][crate::model::ListOrgPolicyViolationsPreviewsResponse::org_policy_violations_previews].
    pub fn set_org_policy_violations_previews<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::OrgPolicyViolationsPreview>,
    {
        use std::iter::Iterator;
        self.org_policy_violations_previews = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListOrgPolicyViolationsPreviewsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListOrgPolicyViolationsPreviewsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.ListOrgPolicyViolationsPreviewsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListOrgPolicyViolationsPreviewsResponse {
    type PageItem = crate::model::OrgPolicyViolationsPreview;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.org_policy_violations_previews
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// GetOrgPolicyViolationsPreviewRequest is the request message for
/// [OrgPolicyViolationsPreviewService.GetOrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService.GetOrgPolicyViolationsPreview].
///
/// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService.GetOrgPolicyViolationsPreview]: crate::client::OrgPolicyViolationsPreviewService::get_org_policy_violations_preview
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetOrgPolicyViolationsPreviewRequest {
    /// Required. The name of the OrgPolicyViolationsPreview to get.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetOrgPolicyViolationsPreviewRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetOrgPolicyViolationsPreviewRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetOrgPolicyViolationsPreviewRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.GetOrgPolicyViolationsPreviewRequest"
    }
}

/// CreateOrgPolicyViolationsPreviewRequest is the request message for
/// [OrgPolicyViolationsPreviewService.CreateOrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService.CreateOrgPolicyViolationsPreview].
///
/// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService.CreateOrgPolicyViolationsPreview]: crate::client::OrgPolicyViolationsPreviewService::create_org_policy_violations_preview
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateOrgPolicyViolationsPreviewRequest {
    /// Required. The organization under which this
    /// [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]
    /// will be created.
    ///
    /// Example: `organizations/my-example-org/locations/global`
    ///
    /// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]: crate::model::OrgPolicyViolationsPreview
    pub parent: std::string::String,

    /// Required. The
    /// [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]
    /// to generate.
    ///
    /// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]: crate::model::OrgPolicyViolationsPreview
    pub org_policy_violations_preview:
        std::option::Option<crate::model::OrgPolicyViolationsPreview>,

    /// Optional. An optional user-specified ID for the
    /// [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview].
    /// If not provided, a random ID will be generated.
    ///
    /// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]: crate::model::OrgPolicyViolationsPreview
    pub org_policy_violations_preview_id: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateOrgPolicyViolationsPreviewRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateOrgPolicyViolationsPreviewRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [org_policy_violations_preview][crate::model::CreateOrgPolicyViolationsPreviewRequest::org_policy_violations_preview].
    pub fn set_org_policy_violations_preview<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::OrgPolicyViolationsPreview>,
    {
        self.org_policy_violations_preview = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [org_policy_violations_preview][crate::model::CreateOrgPolicyViolationsPreviewRequest::org_policy_violations_preview].
    pub fn set_or_clear_org_policy_violations_preview<T>(
        mut self,
        v: std::option::Option<T>,
    ) -> Self
    where
        T: std::convert::Into<crate::model::OrgPolicyViolationsPreview>,
    {
        self.org_policy_violations_preview = v.map(|x| x.into());
        self
    }

    /// Sets the value of [org_policy_violations_preview_id][crate::model::CreateOrgPolicyViolationsPreviewRequest::org_policy_violations_preview_id].
    pub fn set_org_policy_violations_preview_id<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.org_policy_violations_preview_id = v.into();
        self
    }
}

impl wkt::message::Message for CreateOrgPolicyViolationsPreviewRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.CreateOrgPolicyViolationsPreviewRequest"
    }
}

/// ListOrgPolicyViolationsRequest is the request message for
/// [OrgPolicyViolationsPreviewService.ListOrgPolicyViolations][google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService.ListOrgPolicyViolations].
///
/// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService.ListOrgPolicyViolations]: crate::client::OrgPolicyViolationsPreviewService::list_org_policy_violations
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListOrgPolicyViolationsRequest {
    /// Required. The OrgPolicyViolationsPreview to get OrgPolicyViolations from.
    /// Format:
    /// organizations/{organization}/locations/{location}/orgPolicyViolationsPreviews/{orgPolicyViolationsPreview}
    pub parent: std::string::String,

    /// Optional. The maximum number of items to return. The service may return
    /// fewer than this value. If unspecified, at most 1000 items will be returned.
    /// The maximum value is 1000; values above 1000 will be coerced to 1000.
    pub page_size: i32,

    /// Optional. A page token, received from a previous call. Provide this to
    /// retrieve the subsequent page.
    ///
    /// When paginating, all other parameters must match the call that provided the
    /// page token.
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListOrgPolicyViolationsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListOrgPolicyViolationsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListOrgPolicyViolationsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListOrgPolicyViolationsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListOrgPolicyViolationsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.ListOrgPolicyViolationsRequest"
    }
}

/// ListOrgPolicyViolationsResponse is the response message for
/// [OrgPolicyViolationsPreviewService.ListOrgPolicyViolations][google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService.ListOrgPolicyViolations]
///
/// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreviewService.ListOrgPolicyViolations]: crate::client::OrgPolicyViolationsPreviewService::list_org_policy_violations
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListOrgPolicyViolationsResponse {
    /// The list of OrgPolicyViolations
    pub org_policy_violations: std::vec::Vec<crate::model::OrgPolicyViolation>,

    /// A token that you can use to retrieve the next page of results.
    /// If this field is omitted, there are no subsequent pages.
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListOrgPolicyViolationsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [org_policy_violations][crate::model::ListOrgPolicyViolationsResponse::org_policy_violations].
    pub fn set_org_policy_violations<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::OrgPolicyViolation>,
    {
        use std::iter::Iterator;
        self.org_policy_violations = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListOrgPolicyViolationsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListOrgPolicyViolationsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.ListOrgPolicyViolationsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListOrgPolicyViolationsResponse {
    type PageItem = crate::model::OrgPolicyViolation;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.org_policy_violations
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// A resource describing a `Replay`, or simulation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct Replay {
    /// Output only. The resource name of the `Replay`, which has the following
    /// format:
    ///
    /// `{projects|folders|organizations}/{resource-id}/locations/global/replays/{replay-id}`,
    /// where `{resource-id}` is the ID of the project, folder, or organization
    /// that owns the Replay.
    ///
    /// Example:
    /// `projects/my-example-project/locations/global/replays/506a5f7f-38ce-4d7d-8e03-479ce1833c36`
    pub name: std::string::String,

    /// Output only. The current state of the `Replay`.
    pub state: crate::model::replay::State,

    /// Required. The configuration used for the `Replay`.
    pub config: std::option::Option<crate::model::ReplayConfig>,

    /// Output only. Summary statistics about the replayed log entries.
    pub results_summary: std::option::Option<crate::model::replay::ResultsSummary>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl Replay {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::Replay::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [state][crate::model::Replay::state].
    pub fn set_state<T: std::convert::Into<crate::model::replay::State>>(mut self, v: T) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [config][crate::model::Replay::config].
    pub fn set_config<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ReplayConfig>,
    {
        self.config = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [config][crate::model::Replay::config].
    pub fn set_or_clear_config<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ReplayConfig>,
    {
        self.config = v.map(|x| x.into());
        self
    }

    /// Sets the value of [results_summary][crate::model::Replay::results_summary].
    pub fn set_results_summary<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::replay::ResultsSummary>,
    {
        self.results_summary = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [results_summary][crate::model::Replay::results_summary].
    pub fn set_or_clear_results_summary<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::replay::ResultsSummary>,
    {
        self.results_summary = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for Replay {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.Replay"
    }
}

/// Defines additional types related to [Replay].
pub mod replay {
    #[allow(unused_imports)]
    use super::*;

    /// Summary statistics about the replayed log entries.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct ResultsSummary {
        /// The total number of log entries replayed.
        pub log_count: i32,

        /// The number of replayed log entries with no difference between
        /// baseline and simulated policies.
        pub unchanged_count: i32,

        /// The number of replayed log entries with a difference between baseline and
        /// simulated policies.
        pub difference_count: i32,

        /// The number of log entries that could not be replayed.
        pub error_count: i32,

        /// The date of the oldest log entry replayed.
        pub oldest_date: std::option::Option<gtype::model::Date>,

        /// The date of the newest log entry replayed.
        pub newest_date: std::option::Option<gtype::model::Date>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl ResultsSummary {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [log_count][crate::model::replay::ResultsSummary::log_count].
        pub fn set_log_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
            self.log_count = v.into();
            self
        }

        /// Sets the value of [unchanged_count][crate::model::replay::ResultsSummary::unchanged_count].
        pub fn set_unchanged_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
            self.unchanged_count = v.into();
            self
        }

        /// Sets the value of [difference_count][crate::model::replay::ResultsSummary::difference_count].
        pub fn set_difference_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
            self.difference_count = v.into();
            self
        }

        /// Sets the value of [error_count][crate::model::replay::ResultsSummary::error_count].
        pub fn set_error_count<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
            self.error_count = v.into();
            self
        }

        /// Sets the value of [oldest_date][crate::model::replay::ResultsSummary::oldest_date].
        pub fn set_oldest_date<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<gtype::model::Date>,
        {
            self.oldest_date = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [oldest_date][crate::model::replay::ResultsSummary::oldest_date].
        pub fn set_or_clear_oldest_date<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<gtype::model::Date>,
        {
            self.oldest_date = v.map(|x| x.into());
            self
        }

        /// Sets the value of [newest_date][crate::model::replay::ResultsSummary::newest_date].
        pub fn set_newest_date<T>(mut self, v: T) -> Self
        where
            T: std::convert::Into<gtype::model::Date>,
        {
            self.newest_date = std::option::Option::Some(v.into());
            self
        }

        /// Sets or clears the value of [newest_date][crate::model::replay::ResultsSummary::newest_date].
        pub fn set_or_clear_newest_date<T>(mut self, v: std::option::Option<T>) -> Self
        where
            T: std::convert::Into<gtype::model::Date>,
        {
            self.newest_date = v.map(|x| x.into());
            self
        }
    }

    impl wkt::message::Message for ResultsSummary {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.policysimulator.v1.Replay.ResultsSummary"
        }
    }

    /// The current state of the [Replay][google.cloud.policysimulator.v1.Replay].
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Default value. This value is unused.
        Unspecified,
        /// The `Replay` has not started yet.
        Pending,
        /// The `Replay` is currently running.
        Running,
        /// The `Replay` has successfully completed.
        Succeeded,
        /// The `Replay` has finished with an error.
        Failed,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Pending => std::option::Option::Some(1),
                Self::Running => std::option::Option::Some(2),
                Self::Succeeded => std::option::Option::Some(3),
                Self::Failed => std::option::Option::Some(4),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Pending => std::option::Option::Some("PENDING"),
                Self::Running => std::option::Option::Some("RUNNING"),
                Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
                Self::Failed => std::option::Option::Some("FAILED"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Pending,
                2 => Self::Running,
                3 => Self::Succeeded,
                4 => Self::Failed,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "PENDING" => Self::Pending,
                "RUNNING" => Self::Running,
                "SUCCEEDED" => Self::Succeeded,
                "FAILED" => Self::Failed,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Pending => serializer.serialize_i32(1),
                Self::Running => serializer.serialize_i32(2),
                Self::Succeeded => serializer.serialize_i32(3),
                Self::Failed => serializer.serialize_i32(4),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.policysimulator.v1.Replay.State",
            ))
        }
    }
}

/// The result of replaying a single access tuple against a simulated state.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ReplayResult {
    /// The resource name of the `ReplayResult`, in the following format:
    ///
    /// `{projects|folders|organizations}/{resource-id}/locations/global/replays/{replay-id}/results/{replay-result-id}`,
    /// where `{resource-id}` is the ID of the project, folder, or organization
    /// that owns the [Replay][google.cloud.policysimulator.v1.Replay].
    ///
    /// Example:
    /// `projects/my-example-project/locations/global/replays/506a5f7f-38ce-4d7d-8e03-479ce1833c36/results/1234`
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    pub name: std::string::String,

    /// The [Replay][google.cloud.policysimulator.v1.Replay] that the access tuple
    /// was included in.
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    pub parent: std::string::String,

    /// The access tuple that was replayed. This field includes information about
    /// the principal, resource, and permission that were involved in the access
    /// attempt.
    pub access_tuple: std::option::Option<crate::model::AccessTuple>,

    /// The latest date this access tuple was seen in the logs.
    pub last_seen_date: std::option::Option<gtype::model::Date>,

    /// The result of replaying the access tuple.
    pub result: std::option::Option<crate::model::replay_result::Result>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ReplayResult {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::ReplayResult::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [parent][crate::model::ReplayResult::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [access_tuple][crate::model::ReplayResult::access_tuple].
    pub fn set_access_tuple<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::AccessTuple>,
    {
        self.access_tuple = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [access_tuple][crate::model::ReplayResult::access_tuple].
    pub fn set_or_clear_access_tuple<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::AccessTuple>,
    {
        self.access_tuple = v.map(|x| x.into());
        self
    }

    /// Sets the value of [last_seen_date][crate::model::ReplayResult::last_seen_date].
    pub fn set_last_seen_date<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<gtype::model::Date>,
    {
        self.last_seen_date = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [last_seen_date][crate::model::ReplayResult::last_seen_date].
    pub fn set_or_clear_last_seen_date<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<gtype::model::Date>,
    {
        self.last_seen_date = v.map(|x| x.into());
        self
    }

    /// Sets the value of [result][crate::model::ReplayResult::result].
    ///
    /// Note that all the setters affecting `result` are mutually
    /// exclusive.
    pub fn set_result<
        T: std::convert::Into<std::option::Option<crate::model::replay_result::Result>>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.result = v.into();
        self
    }

    /// The value of [result][crate::model::ReplayResult::result]
    /// if it holds a `Diff`, `None` if the field is not set or
    /// holds a different branch.
    pub fn diff(&self) -> std::option::Option<&std::boxed::Box<crate::model::ReplayDiff>> {
        #[allow(unreachable_patterns)]
        self.result.as_ref().and_then(|v| match v {
            crate::model::replay_result::Result::Diff(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [result][crate::model::ReplayResult::result]
    /// to hold a `Diff`.
    ///
    /// Note that all the setters affecting `result` are
    /// mutually exclusive.
    pub fn set_diff<T: std::convert::Into<std::boxed::Box<crate::model::ReplayDiff>>>(
        mut self,
        v: T,
    ) -> Self {
        self.result =
            std::option::Option::Some(crate::model::replay_result::Result::Diff(v.into()));
        self
    }

    /// The value of [result][crate::model::ReplayResult::result]
    /// if it holds a `Error`, `None` if the field is not set or
    /// holds a different branch.
    pub fn error(&self) -> std::option::Option<&std::boxed::Box<rpc::model::Status>> {
        #[allow(unreachable_patterns)]
        self.result.as_ref().and_then(|v| match v {
            crate::model::replay_result::Result::Error(v) => std::option::Option::Some(v),
            _ => std::option::Option::None,
        })
    }

    /// Sets the value of [result][crate::model::ReplayResult::result]
    /// to hold a `Error`.
    ///
    /// Note that all the setters affecting `result` are
    /// mutually exclusive.
    pub fn set_error<T: std::convert::Into<std::boxed::Box<rpc::model::Status>>>(
        mut self,
        v: T,
    ) -> Self {
        self.result =
            std::option::Option::Some(crate::model::replay_result::Result::Error(v.into()));
        self
    }
}

impl wkt::message::Message for ReplayResult {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.ReplayResult"
    }
}

/// Defines additional types related to [ReplayResult].
pub mod replay_result {
    #[allow(unused_imports)]
    use super::*;

    /// The result of replaying the access tuple.
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Result {
        /// The difference between the principal's access under the current
        /// (baseline) policies and the principal's access under the proposed
        /// (simulated) policies.
        ///
        /// This field is only included for access tuples that were successfully
        /// replayed and had different results under the current policies and the
        /// proposed policies.
        Diff(std::boxed::Box<crate::model::ReplayDiff>),
        /// The error that caused the access tuple replay to fail.
        ///
        /// This field is only included for access tuples that were not replayed
        /// successfully.
        Error(std::boxed::Box<rpc::model::Status>),
    }
}

/// Request message for
/// [Simulator.CreateReplay][google.cloud.policysimulator.v1.Simulator.CreateReplay].
///
/// [google.cloud.policysimulator.v1.Simulator.CreateReplay]: crate::client::Simulator::create_replay
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct CreateReplayRequest {
    /// Required. The parent resource where this
    /// [Replay][google.cloud.policysimulator.v1.Replay] will be created. This
    /// resource must be a project, folder, or organization with a location.
    ///
    /// Example: `projects/my-example-project/locations/global`
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    pub parent: std::string::String,

    /// Required. The [Replay][google.cloud.policysimulator.v1.Replay] to create.
    /// Set `Replay.ReplayConfig` to configure the replay.
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    pub replay: std::option::Option<crate::model::Replay>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl CreateReplayRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::CreateReplayRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [replay][crate::model::CreateReplayRequest::replay].
    pub fn set_replay<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::Replay>,
    {
        self.replay = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [replay][crate::model::CreateReplayRequest::replay].
    pub fn set_or_clear_replay<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::Replay>,
    {
        self.replay = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for CreateReplayRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.CreateReplayRequest"
    }
}

/// Metadata about a Replay operation.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ReplayOperationMetadata {
    /// Time when the request was received.
    pub start_time: std::option::Option<wkt::Timestamp>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ReplayOperationMetadata {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [start_time][crate::model::ReplayOperationMetadata::start_time].
    pub fn set_start_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [start_time][crate::model::ReplayOperationMetadata::start_time].
    pub fn set_or_clear_start_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.start_time = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for ReplayOperationMetadata {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.ReplayOperationMetadata"
    }
}

/// Request message for
/// [Simulator.GetReplay][google.cloud.policysimulator.v1.Simulator.GetReplay].
///
/// [google.cloud.policysimulator.v1.Simulator.GetReplay]: crate::client::Simulator::get_replay
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetReplayRequest {
    /// Required. The name of the [Replay][google.cloud.policysimulator.v1.Replay]
    /// to retrieve, in the following format:
    ///
    /// `{projects|folders|organizations}/{resource-id}/locations/global/replays/{replay-id}`,
    /// where `{resource-id}` is the ID of the project, folder, or organization
    /// that owns the `Replay`.
    ///
    /// Example:
    /// `projects/my-example-project/locations/global/replays/506a5f7f-38ce-4d7d-8e03-479ce1833c36`
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetReplayRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetReplayRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetReplayRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.GetReplayRequest"
    }
}

/// Request message for
/// [Simulator.ListReplayResults][google.cloud.policysimulator.v1.Simulator.ListReplayResults].
///
/// [google.cloud.policysimulator.v1.Simulator.ListReplayResults]: crate::client::Simulator::list_replay_results
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListReplayResultsRequest {
    /// Required. The [Replay][google.cloud.policysimulator.v1.Replay] whose
    /// results are listed, in the following format:
    ///
    /// `{projects|folders|organizations}/{resource-id}/locations/global/replays/{replay-id}`
    ///
    /// Example:
    /// `projects/my-project/locations/global/replays/506a5f7f-38ce-4d7d-8e03-479ce1833c36`
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    pub parent: std::string::String,

    /// The maximum number of
    /// [ReplayResult][google.cloud.policysimulator.v1.ReplayResult] objects to
    /// return. Defaults to 5000.
    ///
    /// The maximum value is 5000; values above 5000 are rounded down to 5000.
    ///
    /// [google.cloud.policysimulator.v1.ReplayResult]: crate::model::ReplayResult
    pub page_size: i32,

    /// A page token, received from a previous
    /// [Simulator.ListReplayResults][google.cloud.policysimulator.v1.Simulator.ListReplayResults]
    /// call. Provide this token to retrieve the next page of results.
    ///
    /// When paginating, all other parameters provided to
    /// [Simulator.ListReplayResults[] must match the call that provided the page
    /// token.
    ///
    /// [google.cloud.policysimulator.v1.Simulator.ListReplayResults]: crate::client::Simulator::list_replay_results
    pub page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListReplayResultsRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListReplayResultsRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListReplayResultsRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListReplayResultsRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListReplayResultsRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.ListReplayResultsRequest"
    }
}

/// Response message for
/// [Simulator.ListReplayResults][google.cloud.policysimulator.v1.Simulator.ListReplayResults].
///
/// [google.cloud.policysimulator.v1.Simulator.ListReplayResults]: crate::client::Simulator::list_replay_results
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListReplayResultsResponse {
    /// The results of running a [Replay][google.cloud.policysimulator.v1.Replay].
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    pub replay_results: std::vec::Vec<crate::model::ReplayResult>,

    /// A token that you can use to retrieve the next page of
    /// [ReplayResult][google.cloud.policysimulator.v1.ReplayResult] objects. If
    /// this field is omitted, there are no subsequent pages.
    ///
    /// [google.cloud.policysimulator.v1.ReplayResult]: crate::model::ReplayResult
    pub next_page_token: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListReplayResultsResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [replay_results][crate::model::ListReplayResultsResponse::replay_results].
    pub fn set_replay_results<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ReplayResult>,
    {
        use std::iter::Iterator;
        self.replay_results = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListReplayResultsResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }
}

impl wkt::message::Message for ListReplayResultsResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.ListReplayResultsResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListReplayResultsResponse {
    type PageItem = crate::model::ReplayResult;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.replay_results
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// The configuration used for a
/// [Replay][google.cloud.policysimulator.v1.Replay].
///
/// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ReplayConfig {
    /// A mapping of the resources that you want to simulate policies for and the
    /// policies that you want to simulate.
    ///
    /// Keys are the full resource names for the resources. For example,
    /// `//cloudresourcemanager.googleapis.com/projects/my-project`.
    /// For examples of full resource names for Google Cloud services, see
    /// <https://cloud.google.com/iam/help/troubleshooter/full-resource-names>.
    ///
    /// Values are [Policy][google.iam.v1.Policy] objects representing the policies
    /// that you want to simulate.
    ///
    /// Replays automatically take into account any IAM policies inherited through
    /// the resource hierarchy, and any policies set on descendant resources. You
    /// do not need to include these policies in the policy overlay.
    ///
    /// [google.iam.v1.Policy]: iam_v1::model::Policy
    pub policy_overlay: std::collections::HashMap<std::string::String, iam_v1::model::Policy>,

    /// The logs to use as input for the
    /// [Replay][google.cloud.policysimulator.v1.Replay].
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    pub log_source: crate::model::replay_config::LogSource,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ReplayConfig {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [policy_overlay][crate::model::ReplayConfig::policy_overlay].
    pub fn set_policy_overlay<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<iam_v1::model::Policy>,
    {
        use std::iter::Iterator;
        self.policy_overlay = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [log_source][crate::model::ReplayConfig::log_source].
    pub fn set_log_source<T: std::convert::Into<crate::model::replay_config::LogSource>>(
        mut self,
        v: T,
    ) -> Self {
        self.log_source = v.into();
        self
    }
}

impl wkt::message::Message for ReplayConfig {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.ReplayConfig"
    }
}

/// Defines additional types related to [ReplayConfig].
pub mod replay_config {
    #[allow(unused_imports)]
    use super::*;

    /// The source of the logs to use for a
    /// [Replay][google.cloud.policysimulator.v1.Replay].
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum LogSource {
        /// An unspecified log source.
        /// If the log source is unspecified, the
        /// [Replay][google.cloud.policysimulator.v1.Replay] defaults to using
        /// `RECENT_ACCESSES`.
        ///
        /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
        Unspecified,
        /// All access logs from the last 90 days. These logs may not include logs
        /// from the most recent 7 days.
        RecentAccesses,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [LogSource::value] or
        /// [LogSource::name].
        UnknownValue(log_source::UnknownValue),
    }

    #[doc(hidden)]
    pub mod log_source {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl LogSource {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::RecentAccesses => std::option::Option::Some(1),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("LOG_SOURCE_UNSPECIFIED"),
                Self::RecentAccesses => std::option::Option::Some("RECENT_ACCESSES"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for LogSource {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for LogSource {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for LogSource {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::RecentAccesses,
                _ => Self::UnknownValue(log_source::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for LogSource {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "LOG_SOURCE_UNSPECIFIED" => Self::Unspecified,
                "RECENT_ACCESSES" => Self::RecentAccesses,
                _ => Self::UnknownValue(log_source::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for LogSource {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::RecentAccesses => serializer.serialize_i32(1),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for LogSource {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<LogSource>::new(
                ".google.cloud.policysimulator.v1.ReplayConfig.LogSource",
            ))
        }
    }
}

/// The difference between the results of evaluating an access tuple under
/// the current (baseline) policies and under the proposed (simulated) policies.
/// This difference explains how a principal's access could change if the
/// proposed policies were applied.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ReplayDiff {
    /// A summary and comparison of the principal's access under the current
    /// (baseline) policies and the proposed (simulated) policies for a single
    /// access tuple.
    ///
    /// The evaluation of the principal's access is reported in the
    /// [AccessState][google.cloud.policysimulator.v1.AccessState] field.
    ///
    /// [google.cloud.policysimulator.v1.AccessState]: crate::model::AccessState
    pub access_diff: std::option::Option<crate::model::AccessStateDiff>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ReplayDiff {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [access_diff][crate::model::ReplayDiff::access_diff].
    pub fn set_access_diff<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::AccessStateDiff>,
    {
        self.access_diff = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [access_diff][crate::model::ReplayDiff::access_diff].
    pub fn set_or_clear_access_diff<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::AccessStateDiff>,
    {
        self.access_diff = v.map(|x| x.into());
        self
    }
}

impl wkt::message::Message for ReplayDiff {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.ReplayDiff"
    }
}

/// A summary and comparison of the principal's access under the current
/// (baseline) policies and the proposed (simulated) policies for a single
/// access tuple.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct AccessStateDiff {
    /// The results of evaluating the access tuple under the current (baseline)
    /// policies.
    ///
    /// If the [AccessState][google.cloud.policysimulator.v1.AccessState] couldn't
    /// be fully evaluated, this field explains why.
    ///
    /// [google.cloud.policysimulator.v1.AccessState]: crate::model::AccessState
    pub baseline: std::option::Option<crate::model::ExplainedAccess>,

    /// The results of evaluating the access tuple under the proposed (simulated)
    /// policies.
    ///
    /// If the AccessState couldn't be fully evaluated, this field explains why.
    pub simulated: std::option::Option<crate::model::ExplainedAccess>,

    /// How the principal's access, specified in the AccessState field, changed
    /// between the current (baseline) policies and proposed (simulated) policies.
    pub access_change: crate::model::access_state_diff::AccessChangeType,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl AccessStateDiff {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [baseline][crate::model::AccessStateDiff::baseline].
    pub fn set_baseline<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ExplainedAccess>,
    {
        self.baseline = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [baseline][crate::model::AccessStateDiff::baseline].
    pub fn set_or_clear_baseline<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ExplainedAccess>,
    {
        self.baseline = v.map(|x| x.into());
        self
    }

    /// Sets the value of [simulated][crate::model::AccessStateDiff::simulated].
    pub fn set_simulated<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::ExplainedAccess>,
    {
        self.simulated = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [simulated][crate::model::AccessStateDiff::simulated].
    pub fn set_or_clear_simulated<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::ExplainedAccess>,
    {
        self.simulated = v.map(|x| x.into());
        self
    }

    /// Sets the value of [access_change][crate::model::AccessStateDiff::access_change].
    pub fn set_access_change<
        T: std::convert::Into<crate::model::access_state_diff::AccessChangeType>,
    >(
        mut self,
        v: T,
    ) -> Self {
        self.access_change = v.into();
        self
    }
}

impl wkt::message::Message for AccessStateDiff {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.AccessStateDiff"
    }
}

/// Defines additional types related to [AccessStateDiff].
pub mod access_state_diff {
    #[allow(unused_imports)]
    use super::*;

    /// How the principal's access, specified in the AccessState field, changed
    /// between the current (baseline) policies and proposed (simulated) policies.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum AccessChangeType {
        /// Default value. This value is unused.
        Unspecified,
        /// The principal's access did not change.
        /// This includes the case where both baseline and simulated are UNKNOWN,
        /// but the unknown information is equivalent.
        NoChange,
        /// The principal's access under both the current policies and the proposed
        /// policies is `UNKNOWN`, but the unknown information differs between them.
        UnknownChange,
        /// The principal had access under the current policies (`GRANTED`), but will
        /// no longer have access after the proposed changes (`NOT_GRANTED`).
        AccessRevoked,
        /// The principal did not have access under the current policies
        /// (`NOT_GRANTED`), but will have access after the proposed changes
        /// (`GRANTED`).
        AccessGained,
        /// This result can occur for the following reasons:
        ///
        /// * The principal had access under the current policies (`GRANTED`), but
        ///   their access after the proposed changes is `UNKNOWN`.
        ///
        /// * The principal's access under the current policies is `UNKNOWN`, but
        ///   they
        ///   will not have access after the proposed changes (`NOT_GRANTED`).
        ///
        AccessMaybeRevoked,
        /// This result can occur for the following reasons:
        ///
        /// * The principal did not have access under the current policies
        ///   (`NOT_GRANTED`), but their access after the proposed changes is
        ///   `UNKNOWN`.
        ///
        /// * The principal's access under the current policies is `UNKNOWN`, but
        ///   they will have access after the proposed changes (`GRANTED`).
        ///
        AccessMaybeGained,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [AccessChangeType::value] or
        /// [AccessChangeType::name].
        UnknownValue(access_change_type::UnknownValue),
    }

    #[doc(hidden)]
    pub mod access_change_type {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl AccessChangeType {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::NoChange => std::option::Option::Some(1),
                Self::UnknownChange => std::option::Option::Some(2),
                Self::AccessRevoked => std::option::Option::Some(3),
                Self::AccessGained => std::option::Option::Some(4),
                Self::AccessMaybeRevoked => std::option::Option::Some(5),
                Self::AccessMaybeGained => std::option::Option::Some(6),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("ACCESS_CHANGE_TYPE_UNSPECIFIED"),
                Self::NoChange => std::option::Option::Some("NO_CHANGE"),
                Self::UnknownChange => std::option::Option::Some("UNKNOWN_CHANGE"),
                Self::AccessRevoked => std::option::Option::Some("ACCESS_REVOKED"),
                Self::AccessGained => std::option::Option::Some("ACCESS_GAINED"),
                Self::AccessMaybeRevoked => std::option::Option::Some("ACCESS_MAYBE_REVOKED"),
                Self::AccessMaybeGained => std::option::Option::Some("ACCESS_MAYBE_GAINED"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for AccessChangeType {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for AccessChangeType {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for AccessChangeType {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::NoChange,
                2 => Self::UnknownChange,
                3 => Self::AccessRevoked,
                4 => Self::AccessGained,
                5 => Self::AccessMaybeRevoked,
                6 => Self::AccessMaybeGained,
                _ => Self::UnknownValue(access_change_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for AccessChangeType {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "ACCESS_CHANGE_TYPE_UNSPECIFIED" => Self::Unspecified,
                "NO_CHANGE" => Self::NoChange,
                "UNKNOWN_CHANGE" => Self::UnknownChange,
                "ACCESS_REVOKED" => Self::AccessRevoked,
                "ACCESS_GAINED" => Self::AccessGained,
                "ACCESS_MAYBE_REVOKED" => Self::AccessMaybeRevoked,
                "ACCESS_MAYBE_GAINED" => Self::AccessMaybeGained,
                _ => Self::UnknownValue(access_change_type::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for AccessChangeType {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::NoChange => serializer.serialize_i32(1),
                Self::UnknownChange => serializer.serialize_i32(2),
                Self::AccessRevoked => serializer.serialize_i32(3),
                Self::AccessGained => serializer.serialize_i32(4),
                Self::AccessMaybeRevoked => serializer.serialize_i32(5),
                Self::AccessMaybeGained => serializer.serialize_i32(6),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for AccessChangeType {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<AccessChangeType>::new(
                ".google.cloud.policysimulator.v1.AccessStateDiff.AccessChangeType",
            ))
        }
    }
}

/// Details about how a set of policies, listed in
/// [ExplainedPolicy][google.cloud.policysimulator.v1.ExplainedPolicy], resulted
/// in a certain [AccessState][google.cloud.policysimulator.v1.AccessState] when
/// replaying an access tuple.
///
/// [google.cloud.policysimulator.v1.AccessState]: crate::model::AccessState
/// [google.cloud.policysimulator.v1.ExplainedPolicy]: crate::model::ExplainedPolicy
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ExplainedAccess {
    /// Whether the principal in the access tuple has permission to access the
    /// resource in the access tuple under the given policies.
    pub access_state: crate::model::AccessState,

    /// If the [AccessState][google.cloud.policysimulator.v1.AccessState] is
    /// `UNKNOWN`, this field contains the policies that led to that result.
    ///
    /// If the `AccessState` is `GRANTED` or `NOT_GRANTED`, this field is
    /// omitted.
    ///
    /// [google.cloud.policysimulator.v1.AccessState]: crate::model::AccessState
    pub policies: std::vec::Vec<crate::model::ExplainedPolicy>,

    /// If the [AccessState][google.cloud.policysimulator.v1.AccessState] is
    /// `UNKNOWN`, this field contains a list of errors explaining why the result
    /// is `UNKNOWN`.
    ///
    /// If the `AccessState` is `GRANTED` or `NOT_GRANTED`, this field is
    /// omitted.
    ///
    /// [google.cloud.policysimulator.v1.AccessState]: crate::model::AccessState
    pub errors: std::vec::Vec<rpc::model::Status>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ExplainedAccess {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [access_state][crate::model::ExplainedAccess::access_state].
    pub fn set_access_state<T: std::convert::Into<crate::model::AccessState>>(
        mut self,
        v: T,
    ) -> Self {
        self.access_state = v.into();
        self
    }

    /// Sets the value of [policies][crate::model::ExplainedAccess::policies].
    pub fn set_policies<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ExplainedPolicy>,
    {
        use std::iter::Iterator;
        self.policies = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [errors][crate::model::ExplainedAccess::errors].
    pub fn set_errors<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<rpc::model::Status>,
    {
        use std::iter::Iterator;
        self.errors = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ExplainedAccess {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.policysimulator.v1.ExplainedAccess"
    }
}

/// Whether a principal has a permission for a resource.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum AccessState {
    /// Default value. This value is unused.
    Unspecified,
    /// The principal has the permission.
    Granted,
    /// The principal does not have the permission.
    NotGranted,
    /// The principal has the permission only if a condition expression evaluates
    /// to `true`.
    UnknownConditional,
    /// The user who created the
    /// [Replay][google.cloud.policysimulator.v1.Replay] does not have
    /// access to all of the policies that Policy Simulator needs to evaluate.
    ///
    /// [google.cloud.policysimulator.v1.Replay]: crate::model::Replay
    UnknownInfoDenied,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [AccessState::value] or
    /// [AccessState::name].
    UnknownValue(access_state::UnknownValue),
}

#[doc(hidden)]
pub mod access_state {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl AccessState {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Granted => std::option::Option::Some(1),
            Self::NotGranted => std::option::Option::Some(2),
            Self::UnknownConditional => std::option::Option::Some(3),
            Self::UnknownInfoDenied => std::option::Option::Some(4),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("ACCESS_STATE_UNSPECIFIED"),
            Self::Granted => std::option::Option::Some("GRANTED"),
            Self::NotGranted => std::option::Option::Some("NOT_GRANTED"),
            Self::UnknownConditional => std::option::Option::Some("UNKNOWN_CONDITIONAL"),
            Self::UnknownInfoDenied => std::option::Option::Some("UNKNOWN_INFO_DENIED"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for AccessState {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for AccessState {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for AccessState {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Granted,
            2 => Self::NotGranted,
            3 => Self::UnknownConditional,
            4 => Self::UnknownInfoDenied,
            _ => Self::UnknownValue(access_state::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for AccessState {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "ACCESS_STATE_UNSPECIFIED" => Self::Unspecified,
            "GRANTED" => Self::Granted,
            "NOT_GRANTED" => Self::NotGranted,
            "UNKNOWN_CONDITIONAL" => Self::UnknownConditional,
            "UNKNOWN_INFO_DENIED" => Self::UnknownInfoDenied,
            _ => Self::UnknownValue(access_state::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for AccessState {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Granted => serializer.serialize_i32(1),
            Self::NotGranted => serializer.serialize_i32(2),
            Self::UnknownConditional => serializer.serialize_i32(3),
            Self::UnknownInfoDenied => serializer.serialize_i32(4),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for AccessState {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<AccessState>::new(
            ".google.cloud.policysimulator.v1.AccessState",
        ))
    }
}

/// The extent to which a single data point, such as the existence of a binding
/// or whether a binding includes a specific principal, contributes to an overall
/// determination.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum HeuristicRelevance {
    /// Default value. This value is unused.
    Unspecified,
    /// The data point has a limited effect on the result. Changing the data point
    /// is unlikely to affect the overall determination.
    Normal,
    /// The data point has a strong effect on the result. Changing the data point
    /// is likely to affect the overall determination.
    High,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [HeuristicRelevance::value] or
    /// [HeuristicRelevance::name].
    UnknownValue(heuristic_relevance::UnknownValue),
}

#[doc(hidden)]
pub mod heuristic_relevance {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl HeuristicRelevance {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Normal => std::option::Option::Some(1),
            Self::High => std::option::Option::Some(2),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("HEURISTIC_RELEVANCE_UNSPECIFIED"),
            Self::Normal => std::option::Option::Some("NORMAL"),
            Self::High => std::option::Option::Some("HIGH"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for HeuristicRelevance {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for HeuristicRelevance {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for HeuristicRelevance {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Normal,
            2 => Self::High,
            _ => Self::UnknownValue(heuristic_relevance::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for HeuristicRelevance {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "HEURISTIC_RELEVANCE_UNSPECIFIED" => Self::Unspecified,
            "NORMAL" => Self::Normal,
            "HIGH" => Self::High,
            _ => Self::UnknownValue(heuristic_relevance::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for HeuristicRelevance {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Normal => serializer.serialize_i32(1),
            Self::High => serializer.serialize_i32(2),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for HeuristicRelevance {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<HeuristicRelevance>::new(
            ".google.cloud.policysimulator.v1.HeuristicRelevance",
        ))
    }
}

/// The current state of an
/// [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview].
///
/// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]: crate::model::OrgPolicyViolationsPreview
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum PreviewState {
    /// The state is unspecified.
    Unspecified,
    /// The
    /// [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]
    /// has not been created yet.
    ///
    /// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]: crate::model::OrgPolicyViolationsPreview
    PreviewPending,
    /// The
    /// [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]
    /// is currently being created.
    ///
    /// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]: crate::model::OrgPolicyViolationsPreview
    PreviewRunning,
    /// The
    /// [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]
    /// creation finished successfully.
    ///
    /// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]: crate::model::OrgPolicyViolationsPreview
    PreviewSucceeded,
    /// The
    /// [OrgPolicyViolationsPreview][google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]
    /// creation failed with an error.
    ///
    /// [google.cloud.policysimulator.v1.OrgPolicyViolationsPreview]: crate::model::OrgPolicyViolationsPreview
    PreviewFailed,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [PreviewState::value] or
    /// [PreviewState::name].
    UnknownValue(preview_state::UnknownValue),
}

#[doc(hidden)]
pub mod preview_state {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl PreviewState {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::PreviewPending => std::option::Option::Some(1),
            Self::PreviewRunning => std::option::Option::Some(2),
            Self::PreviewSucceeded => std::option::Option::Some(3),
            Self::PreviewFailed => std::option::Option::Some(4),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("PREVIEW_STATE_UNSPECIFIED"),
            Self::PreviewPending => std::option::Option::Some("PREVIEW_PENDING"),
            Self::PreviewRunning => std::option::Option::Some("PREVIEW_RUNNING"),
            Self::PreviewSucceeded => std::option::Option::Some("PREVIEW_SUCCEEDED"),
            Self::PreviewFailed => std::option::Option::Some("PREVIEW_FAILED"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for PreviewState {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for PreviewState {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for PreviewState {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::PreviewPending,
            2 => Self::PreviewRunning,
            3 => Self::PreviewSucceeded,
            4 => Self::PreviewFailed,
            _ => Self::UnknownValue(preview_state::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for PreviewState {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "PREVIEW_STATE_UNSPECIFIED" => Self::Unspecified,
            "PREVIEW_PENDING" => Self::PreviewPending,
            "PREVIEW_RUNNING" => Self::PreviewRunning,
            "PREVIEW_SUCCEEDED" => Self::PreviewSucceeded,
            "PREVIEW_FAILED" => Self::PreviewFailed,
            _ => Self::UnknownValue(preview_state::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for PreviewState {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::PreviewPending => serializer.serialize_i32(1),
            Self::PreviewRunning => serializer.serialize_i32(2),
            Self::PreviewSucceeded => serializer.serialize_i32(3),
            Self::PreviewFailed => serializer.serialize_i32(4),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for PreviewState {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<PreviewState>::new(
            ".google.cloud.policysimulator.v1.PreviewState",
        ))
    }
}
